<template>
  <div class="p-4 h-full">
    <MethodTable ref="table" @edit="onEdit">
      <template #top-tools-right>
        <a-space>
          <a-button type="primary" mb-2 @click="showForm()">新增项目形式</a-button>
        </a-space>
      </template>
    </MethodTable>
    <MethodForm
      v-model:open="visible"
      :edit="isEdit"
      :default-value="defaultValue"
      title="项目形式"
      @success="refresh" />
  </div>
</template>

<script setup lang="ts">
import type { CapitalManage } from '@/apis/capitalManage';
import MethodTable from '@/views/projectMethod/MethodTable.vue';
import MethodForm, { type MethodFormValue } from '@/views/projectMethod/MethodForm.vue';
import { useFormModal } from '@ykst/hooks';
import { useFreshTable } from '@/hooks/display/useFreshTable';
const { open: visible, isEdit, defaultValue, showForm } = useFormModal<MethodFormValue>();

//表格的编辑事件
function onEdit(record: CapitalManage) {
  const { id, year, month, duration_month, use_money, pro_name } = record;
  //弹窗显示和接受参数
  showForm({
    desc: [''],
    title: '设备',
    val_type: '文本框',
    status: true,
    is_required: true,
  });
}
const { table, refresh } = useFreshTable();
</script>

<style scoped></style>

<route lang="yaml">
meta:
  title: 技术经济目标
  menuOrder: 4
  layout: PageDefault
  layoutHasCardWrapper: true
</route>
